Function.RegisterNamespace("System.IO.DirectoryStrategy");

System.IO.DirectoryStrategy.FileSystemObject=function(){
    // IDirectoryStrategy Members
    this.Exists=function(path){
        if(!path)return false;
        var fso=new ActiveXObject("Scripting.FileSystemObject");    
        return fso.FolderExists(path);
    };

    this.GetFiles=function(path){
        var fso=new ActiveXObject("Scripting.FileSystemObject");
        var directory=fso.GetFolder(path);
        if(directory){
            var files=[];
            var fileList=new Enumerator(directory.Files);
            for(; !fileList.atEnd(); fileList.moveNext())files.push(fileList.item().Path);
            return files;
        }
        return null;
    };
    
    this.GetDirectories=function(path){
        var fso=new ActiveXObject("Scripting.FileSystemObject");
        var directory=fso.GetFolder(path);
        if(directory){
            var directories=[];
            var directoryList=new Enumerator(directory.SubFolders);
            for(; !directoryList.atEnd(); directoryList.moveNext())directories.push(directoryList.item().Path);
            return directories;
        }
        return null;
    };

    // IStrategySpecification Members
    this.IsSatisfiedBy=function(candidate){
        return typeof(ActiveXObject)!='undefined';
    };
};

System.IO.DirectoryStrategy.FileSystemObject.Implement(System.IO.DirectoryStrategy.IDirectoryStrategy,'System.IO.DirectoryStrategy.FileSystemObject');
System.IO.DirectoryStrategy.FileSystemObject.Implement(System.Script.Strategy.IStrategySpecification,'System.IO.DirectoryStrategy.FileSystemObject');

System.IO.Directory.Strategies.Add(System.IO.DirectoryStrategy.FileSystemObject);